package GUILayer;

import java.util.ArrayList;

import javax.swing.table.DefaultTableModel;
import ModelLayer.*;
public class LagerVareModel extends DefaultTableModel {
        /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		private ArrayList<LagerVare> lagerVare;

        public LagerVareModel()
        {
            lagerVare = new ArrayList<LagerVare>();
            
        }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }

    
        
    public void setData(ArrayList<LagerVare> lagerVare)
    {
        this.lagerVare = lagerVare;
        fireTableDataChanged();
    }

    public ArrayList<LagerVare> getLagerVare() {
        return lagerVare;
    }
    
    @Override
    public int getColumnCount() {
        return 1;
    }

    @Override
    public int getRowCount() 
    {
        if(lagerVare == null)
        {
            return 0;
        }
        else
        {
            return lagerVare.size();
        }
    }

    @Override
    public String getColumnName(int column) {
        String columnName = "";
        switch(column)
        {
            case 0:
            columnName = "LagerNr";
            break;  
                  
            
        }        
        return columnName;
    }
    
    

    @Override
    public Object getValueAt(int row, int column) 
    {
        Object value = null;
        switch(column)
        {
            case 0:
                value = lagerVare.get(row).getLager().getLagerNr();
                break;
            

        }        
        return value;
    }        
        
}